package _92XiangYuan;

import _92XiangYuan.factory.ShapeFactory;
import _92XiangYuan.impl.Circle;

/**
 * @Test: 享元模式 测试类
 * @author: ZBoHang
 * @time: 2021/9/14 15:52
 */
public class Test {
    private static final String colors[] = {"Red","Green","Blue","White","Black"};

    public static void main(String[] args) {
        for (int i = 0; i < 20; i++) {
            Circle circle = (Circle) ShapeFactory.getCircle(getRandomColor());
            circle.setX(getRandomX());
            circle.setY(getRandomY());
            circle.setRadius(10);
            circle.draw();
        }
    }

    private static String getRandomColor() {
        return colors[((int) (Math.random() * colors.length))];
    }
    private static int getRandomX() {
        return ((int) (Math.random() * 100));
    }
    private static int getRandomY() {
        return ((int) (Math.random() * 100));
    }
}
